﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;

namespace PoemGame.Repository.EF.SQLite
{
    public class DesignDbContextFactory:IDesignTimeDbContextFactory<PoemGameDbContext>
    {
        public PoemGameDbContext CreateDbContext(string[] args)
        {
            var folder = Environment.SpecialFolder.LocalApplicationData;
            var path = Environment.GetFolderPath(folder);
            var DbPath = System.IO.Path.Join(path, "poemgame.db");

            var optionsBuilder = new DbContextOptionsBuilder<PoemGameDbContext>();
            optionsBuilder.UseSqlite($"Data Source={DbPath}",
                x => x.MigrationsAssembly("PoemGame.Repository.EF.SQLite"));

            return new PoemGameDbContext(optionsBuilder.Options);
        }
    }
}